﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Visuals;
using System.Drawing;
using Silvermoon.Controls.Base;
using Silvermoon.Images;

namespace Silvermoon.Controls
{
    /// <summary>
    /// Controls that contains collections of <see cref="T:ItemBase"/>.
    /// </summary>
    public class ListView:ListViewBase
    {
        #region fields

        private Color color;
        private Visual[] visuals = new Visual[1];
        private BackgroundVisual background;

        #endregion
        #region ctor

        public ListView()
            : base()
        {
            TextColor = Color.Black;
        }

        #endregion
        #region props

        public Color Color { get { return color; } set { if (color != value) { color = value; Invalidate(InvalidationFlag.Color); } } }

        #endregion
        #region Methods

        protected override void OnLayout()
        {
            if (Color.IsEmpty)
            {
                Visuals = null;
            }
            else
            {
                if (background == null)
                {
                    background = new BackgroundVisual();
                    background.Texture = SysImages.Rectangle;
                    visuals[0] = background;
                }
                Visuals = visuals;
                background.Size = Size;
            }

            base.OnLayout();
        }
        #endregion


    }
}
